/** @namespace app.model.Report */
const shortid = require('shortid');

module.exports = app => {
    const {STRING, INTEGER, DATE, DATEONLY, BOOLEAN} = app.Sequelize;

    const Report = app.model.define('report', {
        index: {
            type: STRING,
            defaultValue: () => shortid.generate(),
            unique: 'index',
        },
        email_sent: DATE,
        created_at: DATEONLY
    }, {updatedAt: false});

    Report.associate = () => {
        app.model.Report.belongsTo(app.model.Project, {as: 'project', foreignKey: 'project_id'});
    };

    return Report;
};